package com.ruoyi.gas.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gas.domain.ScheduleRegister;
import com.ruoyi.gas.service.IScheduleRegisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 *
 * @author h w
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/gas/register")
public class ScheduleRegisterController extends BaseController
{
    @Autowired
    private IScheduleRegisterService scheduleRegisterService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('gas:register:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScheduleRegister scheduleRegister)
    {
        startPage();
        List<ScheduleRegister> list = scheduleRegisterService.selectScheduleRegisterList(scheduleRegister);
        return getDataTable(list);
    }

    /**
     * 查询列表
     */
//    @PreAuthorize("@ss.hasPermi('gas:register:recentList')")
    @GetMapping("/recentList")
    public List<ScheduleRegister> recentList(ScheduleRegister scheduleRegister)
    {
        return scheduleRegisterService.selectScheduleRegisterRecentList(scheduleRegister);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('gas:register:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScheduleRegister scheduleRegister)
    {
        List<ScheduleRegister> list = scheduleRegisterService.selectScheduleRegisterList(scheduleRegister);
        ExcelUtil<ScheduleRegister> util = new ExcelUtil<ScheduleRegister>(ScheduleRegister.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('gas:register:query')")
    @GetMapping(value = "/{registerId}")
    public AjaxResult getInfo(@PathVariable("registerId") Long registerId)
    {
        return success(scheduleRegisterService.selectScheduleRegisterByRegisterId(registerId));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('gas:register:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScheduleRegister scheduleRegister)
    {
        return toAjax(scheduleRegisterService.insertScheduleRegister(scheduleRegister));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('gas:register:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScheduleRegister scheduleRegister)
    {
        return toAjax(scheduleRegisterService.updateScheduleRegister(scheduleRegister));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('gas:register:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registerIds}")
    public AjaxResult remove(@PathVariable Long[] registerIds)
    {
        return toAjax(scheduleRegisterService.deleteScheduleRegisterByRegisterIds(registerIds));
    }
}
